package com.loan.users.service.impl;

import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.loan.users.dao.IAAdminsDao;
import com.loan.users.pojo.AAdmins;
import com.loan.users.service.IUsersService;

/**
 * 用户相关的service 管理员,用户,用户扩展表 一个service 持有多个dao
 */
@Service("usersService")
public class UsersServiceImpl implements IUsersService
{
	@Resource
	private IAAdminsDao adminsDao;

	@Override
	public AAdmins findOneAdminsService(Map<String, Object> condMap)
	{

		return this.adminsDao.findOne(condMap);
	}

	@Override
	public JSONObject insertOneAdminsService(AAdmins admins)
	{
		JSONObject resultJSON = new JSONObject();
		int res = this.adminsDao.insert(admins);
		
		/*
		 * String str = null;
		 * str.toString();
		 */
		if (res > 0)
		{
			resultJSON.put("code", "0");
			resultJSON.put("info", "添加成功");
			
			
			/*二级结构 */
			JSONObject dataJSON = new JSONObject();
			dataJSON.put("id", admins.getId());
			resultJSON.put("data",dataJSON);
		} else
		{
			resultJSON.put("code", "1");
			resultJSON.put("info", "添加失败");
		}

		return resultJSON;
	}

}
